package com.settlement.system.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.settlement.system.common.base.BaseEntity;
import com.settlement.system.common.enums.DeleteEnum;
import com.settlement.system.common.enums.SysImportErrorDetailStatusEnum;
import com.settlement.system.common.util.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * <p>
 *
 * </p>
 *
 * @author huangrensen
 * @since 2023-10-12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysImportErrorDetail extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 原始数据
     */
    private String dataText;

    /**
     * 原始账单类型
     */
    private String platformAndType;

    /**
     * 关联单号
     */
    private String orderNo;

    /**
     * 队列名称
     */
    private String queueName;

    /**
     * 状态
     */
    private Integer status = SysImportErrorDetailStatusEnum.ERROR.getValue();
    @TableField(exist = false)
    private String statusName;

    /**
     * 备注
     */
    private String remark;

    /**
     * 0 未删除 1 已删除
     */
    private Integer deleted = DeleteEnum.NO.getValue();

    @TableField(exist = false)
    private String uuid;

    // 截取长度超出范围的字段
    public void cutString() {
        if (StringUtils.hasText(this.remark) && this.remark.length() > 2000) {
            this.remark = this.remark.substring(0, 2000);
        }
    }
}
